﻿using Architecture.CrossCutting.RepositoryPattern.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Architecture.CrossCutting.LoggingEntities.Mapping
{
    public class EFLogMap : EntityTypeConfiguration<EFLog>
    {
        public EFLogMap()
        {
            //Primary Key
            this.HasKey(l => l.LogId);

            //define properties
            this.Property(l => l.Query).HasColumnName("Query");
            this.Property(l => l.commandType).HasColumnName("CommandType");
            this.Property(l => l.ExecutionTime).HasColumnName("Duration");
            this.Property(l => l.CorrelationId).HasColumnName("CorrelationId");
            this.Property(l => l.ProviderName).HasColumnName("ProviderName");

            //Computed column
            this.Property(l => l.CreationTime).HasColumnName("CreationTime")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);

            this.ToTable("EFLogs", "dbo");
        }
    }
}
